package com.ciei.dpagm.controller;


import com.alibaba.fastjson.JSONObject;
import com.ciei.dpagm.common.controller.BaseController;
import com.ciei.dpagm.entity.Users;
import com.ciei.dpagm.service.RuleSetService;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("ruleSet")
public class RuleSetController extends BaseController {

	@Autowired
	private RuleSetService ruleSetService;

	@RequestMapping("getConditionalRelationOptionList")
	@ResponseBody
	public JSONObject getConditionalRelationOptionList() {
		return ruleSetService.getConditionalRelationOptionList();
	}


	@RequestMapping("getFactModeOptionList")
	@ResponseBody
	public JSONObject getFactModeOptionList(@RequestBody JSONObject data) {
		return ruleSetService.getFactModeOptionList(data);
	}
	@RequestMapping("getFactModeToComparatorOptionList")
	@ResponseBody
	public JSONObject getFactModeToComparatorOptionList() {
		return ruleSetService.getFactModeToComparatorOptionList();
	}

	@RequestMapping("getFactModeAndComparatorToStandardSpecificationOptionList")
	@ResponseBody
	public JSONObject getFactModeAndComparatorToStandardSpecificationOptionList(@RequestBody JSONObject data) {
		return ruleSetService.getFactModeAndComparatorToStandardSpecificationOptionList(data);
	}

	@RequestMapping("init")
	@ResponseBody
	public JSONObject init(@RequestBody JSONObject data) {
		return ruleSetService.init(data);
	}

	@RequestMapping("edit")
	@ResponseBody
	public JSONObject edit(@RequestBody JSONObject data) {
		Users user = (Users) SecurityUtils.getSubject().getPrincipal();
		return ruleSetService.edit(data,user);
	}

	@RequestMapping("getModelOptionList")
	@ResponseBody
	public JSONObject getModelOptionList() {
		return ruleSetService.getModelOptionList();
	}

	@RequestMapping("loadGrid")
	@ResponseBody
	public JSONObject loadGrid(@RequestBody JSONObject query){
		return ruleSetService.loadGrid(query);
	}

	@RequestMapping("initParameterConfiguration")
	@ResponseBody
	public JSONObject initParameterConfiguration(@RequestBody JSONObject data) {
		return ruleSetService.initParameterConfiguration(data);
	}


}
